<!doctype html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <title>进销存管理系统</title>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
          integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">


    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script crossorigin="anonymous" integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT" src="https://lib.baomitu.com/jquery/3.3.1/jquery.min.js"></script>
    <link crossorigin="anonymous" integrity="sha384-KZO2FRYNmIHerhfYMjCIUaJeGBRXP7CN24SiNSG+wdDzgwvxWbl16wMVtWiJTcMt" href="https://lib.baomitu.com/select2/4.0.10/css/select2.min.css" rel="stylesheet">
    <script crossorigin="anonymous" integrity="sha384-ys5U0Cq8Egp/8P1f/p70ZdbJFh14SLL6efAG0szbPupkh/rdm0ZwZnm4IbkuXy6X" src="https://lib.baomitu.com/select2/4.0.10/js/select2.full.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
            integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
            crossorigin="anonymous"></script>
    <script crossorigin="anonymous" integrity="sha384-Ysr53n0PIGi7rAduJ+BAMGbxA9RFQwIQfPh2bD9pf1x3vrnDsdX4SlwCNpxmrPIi" src="https://lib.baomitu.com/layer/3.1.1/layer.js"></script>

    <style>
        .select2-container .select2-selection--single {
            height: 38px;
        }
        .select2-container--default .select2-selection--single .select2-selection__rendered {
            line-height: 38px;
        }
        .select2-container--default .select2-selection--single {
            border: 1px solid #ced4da;
        }
        .select2-container--default .select2-selection--single .select2-selection__arrow {
            top: 3px;
            right: 3px;
        }
    </style>

</head>
<body>


<script>
    function ajaxPost() {
        var select = $("#select").val();
        var num = $("#subNum").val();

        if (select == '选择...'){
            alert('请选择型号');
            return false;
        }
        if (num == ''){
            alert('请输入库存');
            return false;
        }

        var formData = $("#myform").serialize();
        $.ajax({
            type: "post",
            url: "{:url('index/outFun')}",
            data: formData,//data传递过去
            success: function (data) {
                layer.msg(data);
                // if (data == 1){
                //     layer.msg('添加成功');
                //
                // }else {
                //     alert('添加失败');
                //     return false;
                // }
            }

        });

    }
</script>
<div class="container">
    <div class="row">
        <div class="col-md-3">
            <br>
        </div>
        <div class="col-md-6">
            <div class="m-6">
                <br><br><br>
                <form id="myform" class="form-signin">
                    <h2 class="form-signin-heading">进销存管理系统</h2>
                    <br>
                    <h4>销售产品</h4>
                    <br>

                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                            <label class="input-group-text" for="select">型号</label>
                        </div>
                        <select class="custom-select form-control " id="select" name="select">
                            <option selected>选择...</option>

                            {foreach $list as $key=>$vo }
                            <option value="{$vo.name}">{$vo.name} | {$vo.firm} | {$vo.num}</option>
                            {/foreach}

                        </select>

                    </div>


                    <script>
                        var selectorx = $('#select').select2();
                    </script>


                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                            <span class="input-group-text" id="num">数量</span>
                        </div>
                        <input type="number" class="form-control" name="num" id="subNum" value="1" aria-label="Username"
                               aria-describedby="basic-addon1" >
                    </div>

                    <button class="btn btn-lg btn-primary  btn-block" type="button" onclick="ajaxPost()">提交</button>
                </form>
                <a class="text-muted " href="{:url('index/mian')}">
                    <button class="btn btn-lg btn-danger btn-block mt-2" type="submit">首页</button>
                </a>
            </div>
        </div>
        <div class="col-md-3">
            <br>
        </div>
    </div>
</div>




<!--<form id="myform">-->
<!--    &lt;!&ndash;这里给表单起个id用于获取表单并序列化&ndash;&gt;-->
<!--    <input type="text" name="account"/>-->
<!--    <input type="password" name="passwd"/>-->
<!--    <button type="button" onclick="ajaxPost()">-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;</button>-->
<!--</form>-->
<!--<div id="content">-->
<!--</div>-->


</body>
</html>